package cn.disignPattern.com.partTwo;

import javax.swing.*;
import java.awt.*;

/**
 * Created by Administrator on 2021/6/23 0023.
 */
public class SwingObserverExample {

    JFrame jFrame;

    public static void main(String[] args) {
        SwingObserverExample example = new SwingObserverExample();
        example.go();
    }

    public void go(){
        jFrame = new JFrame();
//        jFrame.setLayout(null);
//        jFrame.setBounds(200, 400,200,400);
        JButton jButton = new JButton("should i do it?");
        jButton.addActionListener(event -> {
            String actionCommand = event.getActionCommand();
            System.out.println(actionCommand +":Don't do it , you might regret it");
        });
        jButton.addActionListener(event -> {
            String actionCommand = event.getActionCommand();
            System.out.println(actionCommand +":common on ,do it");
        });
        jFrame.getContentPane().add(BorderLayout.CENTER, jButton);
        jFrame.setVisible(true);
    }
}